package com.puzzlebazar.client.squaregrid.view;

import com.puzzlebazar.client.util.Vec2i;

public class VertexHighlighterBasic implements VertexHighlighter {


	private final DrawableLayer decorator;
	private final String style;
	private final String name;
	
	private int pixelSize = 5;	
	
	/**
	 * Create an object that is able to highlight vertices of a square grid using
	 * a standard square highlight.
	 * 
	 * @param decorator The decorator into which to put drawables resulting from highlighting
	 * @param style The style to use for highlighting  (can be a space separated list)
	 * @param name The name to use for highlighting drawables
	 */
	public VertexHighlighterBasic( DrawableLayer decorator, String style, String name ) {
		this.decorator = decorator;
		this.style = style;
		this.name = name;
	}
	
	@Override
	public void highlightVertex(Vec2i loc) throws Exception {
		DrawableUtils.addVertex( loc, decorator, style, name, pixelSize);
	}

	@Override
	public void unhighlightVertex(Vec2i loc) throws Exception {
		DrawableUtils.removeVertex( loc, decorator, name );
	}

	@Override
	public void unhighlightAllVertices() {
		decorator.removeDrawable(name);
	}
	
	/**
	 * Sets the size, in pixel, of the highlighted vertex
	 * 
	 * @param pixelSize The size, in pixel
	 */
	public void setPixelSize( int pixelSize ) {
		this.pixelSize = pixelSize;
	}
	
}
